package pl.diagnoser.server.persistance.map;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import pl.diagnoser.client.dto.UserDTO;

@Entity
@Table(name = "T_USER")
public class User implements Serializable {
	
	private static final long serialVersionUID = 1L;
	private long userID;
	private String name;
	private String lastname;
	private String login;
	private String password;
	private int isAdministrator;
	
	public User() {}
	public User(String name, String lastname, String login, String password,
			int isAdministrator) {
		
		super();
		this.name = name;
		this.lastname = lastname;
		this.login = login;
		this.password = password;
		this.isAdministrator = isAdministrator;
	}
	
	public User(UserDTO user) {
		super();
		this.name = user.getName();
		this.lastname = user.getLastname();
		this.login = user.getLogin();
		this.password = user.getPassword();
		this.isAdministrator = user.getIsAdministrator();
	}
	
	@Id
	@GeneratedValue
	@Column( name = "USER_ID", unique = true, nullable = false, length = 10 )
	public long getUserID() {
		return userID;
	}
	public void setUserID(long userID) {
		this.userID = userID;
	}
	
	@Column( name = "NAME", unique = false, nullable = false, length = 255 )
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column( name = "LASTNAME", unique = false, nullable = false, length = 255 )
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	
	@Column( name = "LOGIN", unique = true, nullable = false, length = 255 )
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	
	@Column( name = "PASSWORD", unique = true, nullable = false, length = 255 )
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	@Column( name = "IS_ADMINISTRATOR", unique = false, nullable = false, length = 1 )
	public int getIsAdministrator() {
		return isAdministrator;
	}
	public void setIsAdministrator(int isAdministrator) {
		this.isAdministrator = isAdministrator;
	}
}
